<?php

	include_once "Database.php";

	class Questionnaire
	{
		private $qno;
		private $question;
		private $option1;
		private $option2;
		private $option3;
		private $option4;
		private $correctans;
		private $explanation;
		/*private $examcode;*/
		private $subject;
		/*private $examdate;*/
		/*private $maxmarks;*/
		private $score;
		
		public function setQno($qno)
		{
			$this->qno=$qno;
		}
		
		public function getQno()
		{
			return $this->qno;
		}
		
		public function setQuestion($question)
		{
			$this->question=$question;
		}
		
		public function getQuestion($question_number)
		{
			$db = new Database();
			$response = $db->selectQuery("select question from questionnaire where qid=".$question_number);
			return $response[0];
		}
		
		public function setOption1($option1)
		{
			$this->option1=$option1;
		}
		
		public function getOption1($question_number)
		{
			$db = new Database();
			$response = $db->selectQuery("select option1 from questionnaire where qid=".$question_number);
			return $response[0];
		}
		
		public function setOption2($option2)
		{
			$this->option2=$option2;
		}
		
		public function getOption2($question_number)
		{
			$db = new Database();
			$response = $db->selectQuery("select option2 from questionnaire where qid=".$question_number);
			return $response[0];
		}
		
		public function setOption3($option3)
		{
			$this->option3=$option3;
		}
		
		public function getOption3($question_number)
		{
			$db = new Database();
			$response = $db->selectQuery("select option3 from questionnaire where qid=".$question_number);
			return $response[0];
		}
		
		public function setOption4($option4)
		{
			$this->option4=$option4;
		}
		
		public function getOption4($question_number)
		{
			$db = new Database();
			$response = $db->selectQuery("select option4 from questionnaire where qid=".$question_number);
			return $response[0];
		}
		
		public function setCorrectAns($correctans)
		{
			$this->correctans=$correctans;
		}
		
		public function getCorrectAns($question_number)
		{
			$db = new Database();
			$response = $db->selectQuery("select correctans from questionnaire where qid=".$question_number);
			return $response[0];
		}
		
		public function setExplanation($explanation)
		{
			$this->explanation=$explanation;
		}
		
		public function getExplanation($question_number)
		{
			$db = new Database();
			$response = $db->selectQuery("select explanation from questionnaire where qid=".$question_number);
			return $response[0];

		}
		
		/*public function setExamCode()
		{
			$this->examcode=$examcode;
		}
		
		public function getExamCode()
		{
			return $this->examcode;
		}*/
		
		public function setSubject($subject)
		{
			$this->subject=$subject;
		}
		
		public function getSubject()
		{
			return $this->subject;
		}
		
		/*public function setExamDate($examdate)
		{
			$this->examdate=$examdate;
		}
		
		public function getExamDate()
		{
			return $this->examdate;
		}
		
		public function setMaxMarks($maxmarks)
		{
			$this->maxmarks=$maxmarks;
		}
		
		public function getMaxMarks()
		{
			return $this->maxmarks;
		}
		
		public function setScore($score)
		{
			$this->score=$score;
		}
		
		public function getScore()
		{
			return $this->score;
		}*/
		
		public function createQuestionnaire($code){
			/*$ex=new Exam();*/
			$db= new Database();
			$str="insert into questionnaire(question,option1,option2,option3,option4,correctans,explanation,examcode,subject) values('".$this->question."','".$this->option1."','".$this->option2."','".$this->option3."','".$this->option4."','".$this->correctans."','".$this->explanation."','".$code."','".$this->subject."')";
			$response=$db->query($str);
			echo "Question Insertion ".$response;
		}
		
		public function getQuestionnaire($str)
		{
			$db=new Database();
			/*$str="select * from questionnaire q,exam e where q.examcode=e.examcode and e.avail=1";*/
			$response=$db->printQuestions($str);
			echo $response;
		}
		
		public function getSubjects()
		{
			$db=new Database();
			$str="select distinct(subject) from questionnaire,exam where questionnaire.examcode=exam.examcode and exam.examdate<CURDATE() and avail=0";
			$response=$db->getSubjectList($str);
			echo $response;
		}
		
		public function SubjectsList()
		{
		}
	}
?>
